package SERVLETS;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

import DAO.AnimalDAO;
import MODEL.Animal;

/**
 * Servlet implementation class ChamaCadastarVermifugacao
 */
@WebServlet("/ChamaCadastarVermifugacao")
public class ChamaCadastarVermifugacao extends HttpServlet {
	
	
	private static final long serialVersionUID = 1L;


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		//Cria uma lista do tipo Animal
		List<Animal> ListaAnimal = new ArrayList<Animal>();
		try{
			//Cria e inicializa um objeto da Class AnimalDAO
		AnimalDAO dao=new AnimalDAO();
		//Passa os Valores vindos do metodo listaAnimal para a lista .
		ListaAnimal=dao.listaAnimal();
		}catch (Exception e) {
			e.printStackTrace();
		}
		//Chama a jsp Vermifugacoes e passa a ListaAnimal.
		request.setAttribute("ListarAnimal", ListaAnimal);
		RequestDispatcher d=request.getRequestDispatcher("/Vermifugacoes.jsp");
		d.forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}
